// pages/orderList/orderList.js
var couponList = [];
function CouponBean() {
  var id;
  var score;
  var title;
  var content;
  var money;
  var image;
}
Page({

  /**
   * 页面的初始数据
   */
  data: {
       isSetInfo: false,
       stateList: [
            "可用优惠券","其它.."
       ],

       common_row: {
            caption_class: 'caption',
            value_class: 'value'
       },

       couponArray:[],
  },


  onLoad: function () {
    couponList = [];
    var that = this;
    this.setData({
      isSetInfo:getApp().globalData.isSetInfo
    })
    console.log("测试用户id"+getApp().globalData.account.id)
    var id = getApp().globalData.account.id*1;
    wx.request({
      url:"http://101.37.14.167:8001/Coupon/findCouponByAccount_WeChat_OpenidAndStatus",
      method:"POST",
      data:{
       openid:getApp().globalData.openId,
       status:0
      },
      success:function(res){
          console.log("成功"+getApp().globalData.openId)
          console.log(res)
          var list = res.data.data;
          for(var i=0;i<list.length;i++)
          {
            var couponBean = new CouponBean();
            couponBean.id = res.data.data[i].id;
            couponBean.score = res.data.data[i].score;
            couponBean.title = res.data.data[i].title;
            couponBean.content = res.data.data[i].content;
            couponBean.money = res.data.data[i].money;
            couponBean.image='../../res/images/ic_hotel_image.png';
            couponList.push(couponBean);
          }
          that.setData({
            couponArray:couponList
          })
          console.log(that.data.couponArray)
      },
      fail:function(res){
          console.log("失败"+res)
          
      }
  })
  },
 useCoupon:function(res){
    wx.switchTab({
      url: '../homePage/homePage',
    })
 }

})